<template>
	<view class="contract-edit">
		<cu-custom bgColor="bg-gradual-blue" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">编辑合同</block>
		</cu-custom>
		<form>
			<view class="cu-bar bg-white solid-bottom  margin-top">
				<view class="action">
					<text class="cuIcon-title text-blue"></text>合同信息
				</view>
			</view>
			<view class="cu-form-group">
				<view class="title">合同编号:</view>
				<input  name="input" v-model="contract.num"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">交易金额:</view>
				<input placeholder="请输入交易金额,单位(元)" name="input" v-model="contract.money"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">移交日期:</view>
				<picker mode="contract.date" :value="contract.date"  @change="DateChange">					
				<view class="picker">
						{{contract.date}}
					</view>
				</picker>
			</view>
			
			
			<view class="cu-bar bg-white solid-bottom  margin-top">
				<view class="action">
					<text class="cuIcon-title text-blue"></text>房屋信息
				</view>
			</view>
			

			<view class="cu-form-group">
				<view class="title">权利人身份证号</view>
				<input placeholder="" v-model="house.obligeeIdentityNum"></input>
			</view>	
			<view class="cu-form-group">
				<view class="title">建筑面积</view>
				<input placeholder="平方米" name="input" v-model="hous.buildArea"></input>
			</view>
			<view class="cu-form-group">
				<view class="title">套内建筑面积</view>
				<input placeholder="平方米" name="input" v-model="house.insideBuildArea"></input>
			</view>
			<!-- #ifndef H5 || APP-PLUS || MP-ALIPAY -->
			<view class="cu-form-group">
				<view class="title">房屋坐落</view>
				<picker mode="region" @change="RegionChange" :value="region">
					<view class="picker">
						{{region[0]}}，{{region[1]}}，{{region[2]}}
					</view>
				</picker>
			</view>
			<!-- #endif -->
			<view class="cu-form-group">
				<view class="title">详细地址</view>
				<input placeholder="请输入房屋坐落的详细地址,省市区不用填写" name="input" v-model="location"></input>
			</view>	
		</form>
		<view class="padding">
			<button class="cu-btn block bg-blue margin-tb-sm lg"  @click="contractGenerate">
				合同生成</button>
		</view>
		
		
		
	</view>
</template>

<script>
	export default {
		data() {
			let currentDate = this.getDate({
				format: true
			})
			return {
				region: ['贵州省', '贵阳市', '南明区'],
				contract: {
					num: '',
					money: '',
					date: '2016-9-6'
				},
				location: '',
				house: {
					obligeeIdentityNum: '',
					qzNum: '',
					location: '',
					buildArea: '',
					insideBuildArea: '',
				}
			}
		},
		methods: {
			DateChange(e) {
				this.contract.date = e.detail.value
			},
			contractGenerate () {
				uni.showModal({
					title: '温馨提示',
					content: '请确保合同信息正确',
					cancelText: '取消',
					confirmText: '确定',
					success: res => {
						if (res.confirm) {
							uni.navigateTo({
								url: '/pages/contract-sign/contract-sign'
							})
						}
					}
				})
				
			},
			RegionChange(e) {
				this.region = e.detail.value
			},
			getDate(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();
			
				if (type === 'start') {
					year = year - 60;
				} else if (type === 'end') {
					year = year + 2;
				}
				month = month > 9 ? month : '0' + month;;
				day = day > 9 ? day : '0' + day;
				return `${year}-${month}-${day}`;
			}
		}
	}
</script>

<style lang="scss" scoped>
	.cu-form-group .title {
		min-width: calc(4em + 15px);
	}

</style>
